package com.springboot.kafka;

import java.util.LinkedList;

/**
 * @author: zr
 * @date: 2022-04-17
 */
public class MyQueueTest {

    private LinkedList<Integer> queue = new LinkedList<>();

    public synchronized Integer take() throws InterruptedException {
        if (queue.size() == 0) {
            wait();
        }

        Integer first = queue.getFirst();
        notifyAll();
        return first;
    }

    public synchronized Integer put(Integer item) throws InterruptedException {
        if (queue.size() == Integer.MAX_VALUE) {
            wait();
        }
        queue.addLast(item);
        notifyAll();
        return item;
    }

    public static void main(String[] args) {

    }
}
